<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" errorPage="loi.jsp"%>
 
<%@page import="myBeans.Cart"%>
<%@page import="myBeans.DBProcess"%>
<%@page import="myBeans.Item"%>
<%@page import="myBeans.Book"%><html>
 
    <%
        Cart cart=(Cart)session.getAttribute("gio");
     
        if(request.getParameter("order")!=null){
            String bookID=request.getParameter("id");
            int soluong=Integer.parseInt(request.getParameter("sl"));
            if(cart==null)
                cart=new Cart();
            DBProcess db=new DBProcess();
            Book book=db.getBook(bookID);//lay 1 sp
            Item mh=new Item(book.getBookID(),soluong,book.getPrice());
            //them vào giỏ
            cart.addItem(mh);
             
            session.setAttribute("gio",cart);
             
            response.sendRedirect("cart.jsp");
        }
        else if(request.getParameter("in")!=null){
            response.sendRedirect("Bill.jsp");   
        }
    %>